﻿using System;
using System.Collections;
using System.Collections.Generic;

namespace Allegro.Mathlib
{
    /// <summary>
    /// Collection of data
    /// </summary>
    public interface IDataCollection
    {
        /// <summary>
        /// Get item by item name
        /// </summary>
        /// <param name="dataItemName"></param>
        /// <returns></returns>
        ITaskData this[string dataItemName] { get; set; }

        /// <summary>
        /// Get or set a data object
        /// </summary>
        /// <param name="dataItemName"></param>
        /// <param name="objectName"></param>
        /// <returns></returns>
        object this[string dataItemName, string objectName]{ get; set;}

        /// <summary>
        /// True if the data item is present
        /// </summary>
        /// <param name="dataItemName"></param>
        /// <returns></returns>
        bool HasData(string dataItemName);

        /// <summary>
        /// Returns a dictionary of items in the collection
        /// </summary>
        Dictionary<string, ITaskData> Items{ get; }
    }

    /// <summary>
    /// Task data
    /// </summary>
    public interface ITaskData : IEnumerable
    {
        /// <summary>
        /// Get item by variable name
        /// </summary>
        /// <param name="varName"></param>
        /// <returns></returns>
        object this[string varName] { get; set; }

        /// <summary>
        /// True if the variable is present
        /// </summary>
        /// <param name="varName"></param>
        /// <returns></returns>
        bool HasVariable(string varName);

        /// <summary>
        /// Returns a dictionary of data
        /// </summary>
        Dictionary<string, object> Variables { get; }
    }

    /// <summary>
    /// Task data of specific type T
    /// </summary>
    public interface ITaskData<T> : IEnumerable<T>
    {
        /// <summary>
        /// Get item by variable name
        /// </summary>
        /// <param name="varName"></param>
        /// <returns></returns>
        T this[string varName] { get; set; }

        /// <summary>
        /// True if the variable is present
        /// </summary>
        /// <param name="varName"></param>
        /// <returns></returns>
        bool HasVariable(string varName);

        /// <summary>
        /// Returns a dictionary of data
        /// </summary>
        Dictionary<string, T> Variables { get; }
    }
}
